Imports System.Data.OracleClient

Public Class tcmar02l

  Private rvst_form_idnt As String
  Private rvst_ctrl_idnt As String
  Private rvst_ctrl_indc As String
  Private rvst_ctrl_cptn As String
  Private rvin_syst_labl_hght As Integer = 14
  Private rvin_syst_cmbd_labl_hght As Integer = 28
  Private rvin_syst_data_hght As Integer = 20
  Private rvin_syst_btnx_wdth As Integer = 75
  Private rvin_syst_btnx_hght As Integer = 23
  Private rvin_hrzt_pdng As Integer = 5
  Private rvin_vert_pdng As Integer = 2
  Private rvin_syst_xpnt As Integer = 3
  Private rvin_syst_ypnt As Integer = 20
  Private rvbl_init_endx_cndn As Boolean
  Private rvco_ctrl_cltn As New Collection
  Private mDrData As OracleDataReader

  '-----------------------------------------------------------------------


  Public Sub pvvd_init(ByVal ivst_form_idnt As String)

    Do

      If rvbl_init_endx_cndn = True Then

        Exit Do

      End If

      rvbl_init_endx_cndn = True

      rvst_form_idnt = ivst_form_idnt

      rvvd_init(ivst_form_idnt)

    Loop

  End Sub


  '-----------------------------------------------------------------------


  Private Sub rvvd_init(ByVal ivst_form_idnt As String)

    Dim lvin_ctrl_hght As Integer
    Dim lvin_ctrl_wdth As Integer
    Dim lvin_ctrl_xpnt As Integer
    Dim lvin_ctrl_ypnt As Integer
    Dim lvbl_ftch_endx_cndn As Boolean
    Dim lvbl_frst_cndn As Boolean
    Dim lvbl_ctrl_stat_indc As Boolean
    Dim lvcl_form_ctrl_cltn_tabl As New ttbfccll
    Dim lvcl_ctrl_elmt_clss As tcmel02l


    With lvcl_form_ctrl_cltn_tabl

      .pvst_form_idnt = ivst_form_idnt

      mDrData = .pvvd_rtrv_form_dtls()

      lvbl_frst_cndn = True

      While mDrData.Read

        .pvvd_ftch(lvbl_ftch_endx_cndn)

        If lvbl_frst_cndn = True Then
          lvbl_frst_cndn = False
          rvst_ctrl_idnt = .pvst_ctrl_idnt
          rvst_ctrl_indc = .pvst_ctrl_indc
          rvst_ctrl_cptn = .pvst_ctrl_cptn

        End If

        If (rvst_ctrl_idnt <> .pvst_ctrl_idnt) Or _
           (lvbl_ftch_endx_cndn = True) Then

          lvcl_ctrl_elmt_clss = New tcmel02l

          lvcl_ctrl_elmt_clss.pvin_hght = lvin_ctrl_hght
          lvcl_ctrl_elmt_clss.pvin_wdth = lvin_ctrl_wdth
          lvcl_ctrl_elmt_clss.pvin_xpnt = lvin_ctrl_xpnt
          lvcl_ctrl_elmt_clss.pvin_ypnt = lvin_ctrl_ypnt
          lvcl_ctrl_elmt_clss.pvbl_ctrl_stat = lvbl_ctrl_stat_indc
          lvcl_ctrl_elmt_clss.pvst_ctrl_idnt = rvst_ctrl_idnt
          lvcl_ctrl_elmt_clss.pvst_ctrl_indc = rvst_ctrl_indc
          lvcl_ctrl_elmt_clss.pvst_ctrl_cptn = rvst_ctrl_cptn
          lvcl_ctrl_elmt_clss.pvst_prnt_ctrl_idnt = "form"

          'rvvd_ctrl_type(rvst_ctrl_indc _
          '              , rvst_ctrl_idnt _
          '              , lvcl_ctrl_elmt_clss)

          rvco_ctrl_cltn.Add(lvcl_ctrl_elmt_clss _
                            , rvst_ctrl_idnt)

          rvst_ctrl_idnt = .pvst_ctrl_idnt
          rvst_ctrl_indc = .pvst_ctrl_indc
          rvst_ctrl_cptn = .pvst_ctrl_cptn

        End If

        If lvbl_ftch_endx_cndn = True Then

          Exit While

        End If


        rvvd_calc_hght(.pvst_ctrl_hght_indc _
                      , .pvst_refr_ctrl_idnt _
                      , .pvin_ctrl_attr_valu _
                      , lvin_ctrl_hght)

        rvvd_calc_wdth(.pvst_ctrl_wdth_indc _
                      , .pvst_refr_ctrl_idnt _
                      , .pvin_ctrl_attr_valu _
                      , lvin_ctrl_wdth)

        rvvd_calc_xpnt(.pvst_ctrl_xpnt_indc _
                      , .pvst_refr_ctrl_idnt _
                      , lvin_ctrl_wdth _
                      , .pvin_ctrl_attr_valu _
                      , lvin_ctrl_xpnt)

        rvvd_calc_ypnt(.pvst_ctrl_ypnt_indc _
                      , .pvst_refr_ctrl_idnt _
                      , lvin_ctrl_hght _
                      , .pvin_ctrl_attr_valu _
                      , lvin_ctrl_ypnt)

        lvbl_ctrl_stat_indc = .pvbl_ctrl_stat

      End While

    End With

    rvvd_updt_crtl_prnt(ivst_form_idnt)

  End Sub


  '-----------------------------------------------------------------------


  Public Sub New()

    rvbl_init_endx_cndn = False

  End Sub


  '-----------------------------------------------------------------------


  Protected Overrides Sub Finalize()

    rvbl_init_endx_cndn = False

  End Sub


  '-----------------------------------------------------------------------


  Public Sub pvvd_rint()

    rvbl_init_endx_cndn = True

  End Sub


  '-----------------------------------------------------------------------


  'Private Sub rvvd_ctrl_type(ByVal ivst_ctrl_indc As String _
  '                          , ByVal ivst_ctrl_idnt As String _
  '                          , ByRef nrcl_ctrl_elmt_clss As tcmel02l)

  '  Dim lvcl_grid As tuccm01n
  '  Dim lvcl_text As tuccm03n
  '  Dim lvcl_cmbo As tuccm04n
  '  Dim lvcl_grbx As tuccm05n
  '  Dim lvcl_labl As tuccm06n
  '  Dim lvcl_rbxx As tuccm07n
  '  Dim lvcl_btnx As tuccm08n
  '  Dim lvcl_link As tuccm09n
  '  Dim lvcl_chbx As tuccm10n
  '  Dim lvcl_user_ctrl As tuccm11n

  '  Select Case ivst_ctrl_indc

  '    Case "grid"
  '      lvcl_grid = New tuccm01n
  '      lvcl_grid.pvvd_init(ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_grid

  '    Case "text"
  '      lvcl_text = New tuccm03n
  '      lvcl_text.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_text

  '    Case "cmbo"
  '      lvcl_cmbo = New tuccm04n
  '      lvcl_cmbo.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_cmbo

  '    Case "grbx"
  '      lvcl_grbx = New tuccm05n
  '      lvcl_grbx.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_grbx

  '    Case "labl"
  '      lvcl_labl = New tuccm06n
  '      lvcl_labl.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_labl

  '    Case "rbxx"
  '      lvcl_rbxx = New tuccm07n
  '      lvcl_rbxx.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_rbxx

  '    Case "btnx"
  '      lvcl_btnx = New tuccm08n
  '      lvcl_btnx.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_btnx

  '    Case "link"
  '      lvcl_link = New tuccm09n
  '      lvcl_link.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_link

  '    Case "chbx"
  '      lvcl_chbx = New tuccm10n
  '      lvcl_chbx.pvvd_init(rvst_form_idnt, ivst_ctrl_idnt)
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_chbx

  '    Case "term"
  '      lvcl_user_ctrl = New tuccm11n
  '      nrcl_ctrl_elmt_clss.pvct_ctrl = lvcl_user_ctrl


  '    Case Else
  '      MessageBox.Show _
  '                  ("Not a Valid Option")

  '  End Select

  '  Try

  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Height = nrcl_ctrl_elmt_clss.pvin_hght
  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Width = nrcl_ctrl_elmt_clss.pvin_wdth
  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Left = nrcl_ctrl_elmt_clss.pvin_xpnt
  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Top = nrcl_ctrl_elmt_clss.pvin_ypnt
  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Name = ivst_ctrl_idnt
  '    nrcl_ctrl_elmt_clss.pvct_ctrl.Enabled = _
  '      nrcl_ctrl_elmt_clss.pvbl_ctrl_stat
  '    nrcl_ctrl_elmt_clss.pvst_ctrl_indc = ivst_ctrl_indc

  '    nrcl_ctrl_elmt_clss.pvst_prnt_ctrl_idnt = "form"

  '  Catch ex As Exception

  '  End Try

  'End Sub


  '----------------------------------------------------------------------


  Private Sub rvvd_calc_hght(ByVal ivst_crnt_ctrl_hght_indc As String _
                           , ByVal ivst_refr_ctrl_idnt As String _
                           , ByVal ivin_spcf_valu As Integer _
                           , ByRef orin_crnt_ctrl_hght As Integer)

    Dim lvct_refr_ctrl As tcmel02l

    Select Case ivst_crnt_ctrl_hght_indc

      Case "refr_xxxx"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_hght = lvct_refr_ctrl.pvin_hght

      Case "syst_labl"
        orin_crnt_ctrl_hght = rvin_syst_labl_hght

      Case "syst_data"
        orin_crnt_ctrl_hght = rvin_syst_data_hght

      Case "syst_cmbd_labl"
        orin_crnt_ctrl_hght = rvin_syst_cmbd_labl_hght

      Case "spcf_xxxx"
        orin_crnt_ctrl_hght = ivin_spcf_valu

      Case "syst_btnx"
        orin_crnt_ctrl_hght = rvin_syst_btnx_hght

      Case "naxx_xxxx"

    End Select

  End Sub


  '----------------------------------------------------------------------


  Private Sub rvvd_calc_wdth(ByVal ivst_crnt_ctrl_wdth_indc As String _
                           , ByVal ivst_refr_ctrl_idnt As String _
                           , ByVal ivin_spcf_valu As Integer _
                           , ByRef orin_crnt_ctrl_wdth As Integer)

    Dim lvct_refr_ctrl As tcmel02l

    Select Case ivst_crnt_ctrl_wdth_indc

      Case "refr_xxxx"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_wdth = lvct_refr_ctrl.pvin_wdth

      Case "spcf_xxxx"
        orin_crnt_ctrl_wdth = ivin_spcf_valu

      Case "syst_btnx"
        orin_crnt_ctrl_wdth = rvin_syst_btnx_wdth

      Case "naxx_xxxx"

    End Select

  End Sub


  '----------------------------------------------------------------------


  Private Sub rvvd_calc_ypnt(ByVal ivst_crnt_ctrl_ypnt_indc As String _
                            , ByVal ivst_refr_ctrl_idnt As String _
                            , ByVal ivin_crnt_ctrl_hght As Integer _
                            , ByVal ivin_spcf_valu As Integer _
                            , ByRef orin_crnt_ctrl_ypnt As Integer)

    Dim lvct_refr_ctrl As tcmel02l

    Select Case ivst_crnt_ctrl_ypnt_indc

      Case "topx_yone", "topx_ytwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_ypnt = lvct_refr_ctrl.pvin_ypnt - _
                              ivin_crnt_ctrl_hght - _
                              rvin_vert_pdng


      Case "down_yone", "down_ytwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_ypnt = lvct_refr_ctrl.pvin_ypnt + _
                              lvct_refr_ctrl.pvin_hght + _
                              rvin_vert_pdng

      Case "same_yone"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_ypnt = lvct_refr_ctrl.pvin_ypnt

      Case "same_ytwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_ypnt = lvct_refr_ctrl.pvin_ypnt + _
                              lvct_refr_ctrl.pvin_hght

      Case "spcf_xxxx"
        orin_crnt_ctrl_ypnt = ivin_spcf_valu

      Case "syst_ypnt"
        orin_crnt_ctrl_ypnt = rvin_syst_ypnt

      Case "naxx_xxxx"

    End Select

  End Sub


  '----------------------------------------------------------------------


  Private Sub rvvd_calc_xpnt(ByVal ivst_crnt_ctrl_xpnt_indc As String _
                            , ByVal ivst_refr_ctrl_idnt As String _
                            , ByVal ivin_crnt_ctrl_wdth As Integer _
                            , ByVal ivin_spcf_valu As Integer _
                            , ByRef orin_crnt_ctrl_xpnt As Integer)

    Dim lvct_refr_ctrl As tcmel02l

    Select Case ivst_crnt_ctrl_xpnt_indc

      Case "left_xone"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_xpnt = lvct_refr_ctrl.pvin_xpnt - _
                              ivin_crnt_ctrl_wdth - _
                              rvin_hrzt_pdng

      Case "left_xtwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_xpnt = lvct_refr_ctrl.pvin_xpnt + _
                              lvct_refr_ctrl.pvin_wdth - _
                              ivin_crnt_ctrl_wdth

      Case "rght_xone", "rght_xtwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_xpnt = lvct_refr_ctrl.pvin_xpnt + _
                              lvct_refr_ctrl.pvin_wdth + _
                              rvin_hrzt_pdng

      Case "same_xone"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_xpnt = lvct_refr_ctrl.pvin_xpnt

      Case "same_xtwo"
        lvct_refr_ctrl = rvco_ctrl_cltn.Item(ivst_refr_ctrl_idnt)
        orin_crnt_ctrl_xpnt = lvct_refr_ctrl.pvin_xpnt + _
                              lvct_refr_ctrl.pvin_wdth

      Case "spcf_xxxx"
        orin_crnt_ctrl_xpnt = ivin_spcf_valu

      Case "syst_xpnt"
        orin_crnt_ctrl_xpnt = rvin_syst_xpnt

      Case "naxx_xxxx"

    End Select

  End Sub


  '---------------------------------------------------------------------


  Private Sub rvvd_updt_crtl_prnt(ByVal ivst_form_idnt As String)

    Dim lvcl_chld_ctrl_tabl As New ttbcccll
    Dim lvcl_ctrl_elmt_clss As tcmel02l
    Dim lvbl_ftch_endx_cndn As Boolean

    mDrData = Nothing

    With lvcl_chld_ctrl_tabl

      .pvst_form_idnt = ivst_form_idnt

      mDrData = .pvvd_rtrv_form_ctrl()

      Do

        .pvvd_ftch(mDrData)

        If lvbl_ftch_endx_cndn = True Then

          Exit Do

        End If

        lvcl_ctrl_elmt_clss = rvco_ctrl_cltn.Item(.pvst_ctrl_idnt)

        lvcl_ctrl_elmt_clss.pvst_prnt_ctrl_idnt = .pvst_prnt_ctrl_idnt

      Loop

    End With

  End Sub


  '----------------------------------------------------------------------


  Public Sub pvvd_selc(ByVal ivin_ctrl_indx As Integer _
                      , ByRef orcl_ctrl_elmt As tcmel02l)

    Try
      orcl_ctrl_elmt = rvco_ctrl_cltn.Item(ivin_ctrl_indx)

    Catch ex As Exception

    End Try

  End Sub


  '----------------------------------------------------------------------


  Public Sub pvvd_cltn_cntx(ByRef orin_cltn_cntx As Integer)
    Try
      orin_cltn_cntx = rvco_ctrl_cltn.Count

    Catch ex As Exception

    End Try

  End Sub


  '----------------------------------------------------------------------


  Public Sub pvvd_selc_ctrl(ByVal ivst_ctrl_idnt As String _
                          , ByRef orcl_ctrl_elmt As tcmel02l)

    Try
      orcl_ctrl_elmt = rvco_ctrl_cltn.Item(ivst_ctrl_idnt)

    Catch ex As Exception

    End Try

  End Sub



  '----------------------------------------------------------------------


  Public Function mFnControlCollection() As Collection
    Return rvco_ctrl_cltn
  End Function

End Class
